import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ljy_flutter/get/binding/b_home_widget.dart';
import 'package:ljy_flutter/get/binding/b_homecontroller_binding.dart';
import 'package:ljy_flutter/get/binding/binding_my_controller.dart';

class GetxBindingExample extends StatelessWidget {
  const GetxBindingExample({super.key});

 @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Getx GetxBindingExample'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Obx(() {
              final count = Get.find<BindingMyController>().count;
              return Text('GetxBindingExample 计数器 count: $count', style: const TextStyle(color: Colors.red, fontSize: 20));
            }),
            const SizedBox(height: 20,),

            ElevatedButton(onPressed: (){
              Get.find<BindingMyController>().increment();
            }, child: const Text('GetxBindingExample 增加计数器')),
            
            SizedBox(height: 20,),
            ElevatedButton(onPressed: () {
              Get.to(BHomeWidget(), binding: BHomecontrollerBinding());
            }, child: const Text('跳转去首页')),
          ],
        ),
      ),
    );
  }
}